#ifndef __VZ_APP_COMMON_H
#define __VZ_APP_COMMON_H

#include "pal/protocol/VzClientSDK_LPDefine.h"
#include "pal/protocol/VzClientSDK_CommonDefine.h"
#include <stdbool.h>
#include "uv.h"

#define VZ_RECV_BUF_LEN (1024 * 1024)

#define VZ_RECONNECT_TIME_OUT 2 * 1000
// 摄像机心跳间隔
#define VZ_HEART_BEAT_TIME 3 * 1000

#define HB_LOG_MAX_NUM 600

#define VZ_IMG1_SIZE (1024 * 1024)
#define VZ_IMG2_SIZE (512 * 1024)

#ifndef __PACKED__
#define __PACKED__ __attribute__((__packed__))
#endif

typedef enum _VZ_DATA_TYPE_E
{
    VZ_DATA_TYPE_NONE = -1,
    VZ_DATA_TYPE_JSON = 0,
    VZ_DATA_TYPE_HB = 0x01,
    VZ_DATA_TYPE_BIN,
    VZ_DATA_TYPE_END
} VZ_DATA_TYPE_E;

typedef enum _VZ_JSON_CMD_TYPE_E
{
    VZ_JSON_CMD_TYPE_NONE = 0,
    VZ_JSON_CMD_TYPE_GETSN = 1,
    VZ_JSON_CMD_TYPE_IVSRESULT,
    VZ_JSON_CMD_TYPE_IVSRESULT_JSON,
    VZ_JSON_CMD_TYPE_END,
} VZ_JSON_CMD_TYPE_E;

struct _VZ_HAED_T
{
    char cMagic1;
    char cMagic2;
    unsigned char ucPacketType; /* VZ_DATA_TYPE_E */
    unsigned char ucSeq;
    uint32_t unDataLen; //unsigned char aucDataLen[4];
} __PACKED__;
typedef struct _VZ_HAED_T VZ_HEAD_T;

struct _VZ_PACKET_T
{
    VZ_HEAD_T stHead;
    char acData[0];
} __PACKED__;
typedef struct _VZ_PACKET_T VZ_PACKET_T;

typedef struct _SET_IVSRESULT_T
{
    int nEnable;
    int nFormat;    /* 0 for bin, 1 for json */
    int nReturnImg; /* be return image in result*/
    int nImgType;   /* 0 返回结果全图，1 返回区域小图，2两种图片格式都返回 */
} SET_IVSRESULT_T;

typedef struct _IVSRESULT_BIN_T
{
    TH_PlateResult stDisc;
    char acImg1[VZ_IMG1_SIZE];
    int nImg1Len;
    char acImg2[VZ_IMG2_SIZE];
    int nImg2Len;
    // 73 指令的图片序号， 1B
    unsigned char picTag;
} IVSRESULT_BIN_T;

typedef struct _VZ_GETSNAPSHOT_RESPONSE_S
{
    int stat_code;
    int id;
    int nImageType;    // 0 for jpg
    char acImgData[0]; // notx base64
} VZ_GETSNAPSHOT_RESPONSE_S;

#endif